package com.yzy.soft.system.freemarker.template;

import com.yzy.soft.system.freemarker.*;


import com.yzy.soft.system.freemarker.TemplateKernel;
import com.yzy.soft.system.freemarker.database.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class TemplateDTO extends TemplateKernel {

    private final static Logger logger=LoggerFactory.getLogger(TemplateDTO.class);
    @Override
    public File generateFileType(FileInfo fileInfo, Table table, DBInfo dbInfo) throws Exception {
        JavaFileDto javaFile=((JavaFile)fileInfo).getJavaFileDto();
        final String templateName = "DTO.ftl";
        String tableName = javaFile.getFilename();
        final String path = fileInfo.getDiskPath() + tableName + javaFile.getSuffix();
        logger.info("TemplateDTO path:"+path);
        File file = new File(path);
        Map<String, Object> dataMap = new HashMap<String, Object>();
        dataMap.put("dto_packageName", javaFile.getPackageName());
            dataMap.put("dto_tablename", javaFile.getFilename());
            generateFileByTemplate(templateName, file,fileInfo, dataMap);
            return file;

    }



}
